﻿using System;
using WatiN.Core;

namespace QAHelper.Common
{
    public static class WatiNErrorHelper
    {
        public static string GetErrorMessage(WatiN.Core.Constraints.Constraint constraint, Browser window, string delimeter,string indexOfValue)
        {
            Element ul = window.Element(constraint);
            string errorMessage=string.Empty;
            string[] errorMessages = ul.InnerHtml.Split('\n');

            foreach (string str in errorMessages)
            {
                errorMessage += str.Split(new string[] { delimeter }, StringSplitOptions.None)[0].Substring(ul.InnerHtml.IndexOf(indexOfValue) + 1)+Environment.NewLine;
            }

            return errorMessage;
        }
    }
}
